<?php

namespace App\Http\Controllers;


use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class NoticeController extends Controller
{
    public function lists(){
        $lists = DB::table('notice')->orderBy('id','desc')->paginate(8);
        return response()->json(['code'=>0,'data'=>$lists]);
    }

    public function detail(Request $request){
        $id = $request->input('id',0);
        
        $data = DB::table('notice')->where('id',$id)->first();
        if (empty($data)){
            return response()->json(['code'=>10002,'msg'=>'信息不存在']);
        }
        $data =  objectToArray($data);


        return response()->json(['code'=>0,'data'=>$data]);

    }
}